package com.obas.monitor.service.impl;

import com.obas.business.common.vo.AtMessage;
import com.obas.business.common.vo.TestContext;
import com.obas.model.business.TestPlan;
import com.obas.model.business.TestPlanItem;
import com.obas.monitor.AtCommand;
import com.obas.monitor.MessageProcessor;
import com.obas.monitor.TestContextManager;
import com.obas.monitor.service.ITestMonitorService;

public class ITestMonitorServiceImpl implements ITestMonitorService {
    private MessageProcessor messageProcessor;

    public void setMessageProcessor(MessageProcessor messageProcessor) {
       this.messageProcessor = messageProcessor;
    }

   @Override
   public void startAut(String appId, long scriptId) {
      TestContext context = TestContextManager.getTestContext(appId);
      context.scriptId = scriptId;
      context.ideState = 0;
   }

   @Override
   public void shutDownAut(String pageId) {
      messageProcessor.stopAut(pageId);
   }

   @Override
   public void beginRecord(String pageId) {
      messageProcessor.beginRecord(pageId);
   }

   @Override
   public void endRecord(String pageId) {
      messageProcessor.endRecord(pageId);
   }

   @Override
   public void startPlay(String pageId) {
      messageProcessor.startPlay(pageId);
   }

   @Override
   public void getProperties(String pageId, AtMessage msg) {
      messageProcessor.getProperties(pageId, msg);
   }

   @Override
   public void getTreeRoot(String pageId) {
      messageProcessor.getTreeRoot(pageId);
   }

   @Override
   public void toggleInspectFrame(String pageId, AtMessage msg) {
      messageProcessor.toggleInspectFrame(pageId, msg);
   }

   @Override
   public void toggleInspectMode(String pageId, AtMessage msg) {
      messageProcessor.toggleInspectMode(pageId, msg);
   }

   @Override
   public void getTreeChildren(String pageId, AtMessage msg) {
      messageProcessor.getTreeChildren(pageId, msg);
   }

   @Override
   public void runTestPlanItem(String appId, TestPlanItem item) {
       TestContext context = TestContextManager.getTestContext(appId);
       context.scriptId = item.getTestcaseScriptId();
       context.parameterId = item.getParameterId();
       context.ideState = AtCommand.ideRunning;
   }

   public void runTestPlan(TestPlan testPlan) {

   }

}
